dynamics_graph Module

Provides a lightweight, undirected multigraph container along with the traversal utilities required to analyze the topology of closed-loop mechanisms. Vertices are represented by integer indices, and edges are stored in a simple allocatable array.



Contents


Derived Types

type, public ::  graph

Defines an undirected multigraph. Multiple edges between the same pair of vertices, as well as self-loops, are permitted.

Type-Bound Procedures

procedure , public :: add_edge => gr_add_edge Subroutine
procedure , public :: build_spanning_tree => gr_spanning_tree Function
procedure , public :: find_independent_loops => gr_find_loops Function
procedure , public :: get_adjacent_edges => gr_adjacent_edges Function
procedure , public :: get_edge => gr_get_edge Function
procedure , public :: get_edge_count => gr_edge_count Function
procedure , public :: get_independent_loop_count => gr_loop_count Function
procedure , public :: get_vertex_count => gr_vertex_count Function
procedure , public :: initialize => gr_initialize Subroutine

type, public ::  graph_edge

Defines an undirected edge connecting two vertices.

Components

Type Visibility Attributes Name Initial
integer(kind=int32), public :: vertex_1 = 0

The index of the first vertex.

integer(kind=int32), public :: vertex_2 = 0

The index of the second vertex.

type, public ::  graph_loop

Describes an independent loop within the graph. The loop is defined by an edge that is not part of the spanning tree; the loop itself is closed by the tree paths leading to each of the edge's vertices.

Components

Type Visibility Attributes Name Initial
integer(kind=int32), public :: cut_edge = 0

The index of the edge closing the loop.

integer(kind=int32), public :: vertex_1 = 0

The first vertex of the cut edge.

integer(kind=int32), public :: vertex_2 = 0

The second vertex of the cut edge.

type, public ::  graph_path

Describes a path through a graph.

Components

Type Visibility Attributes Name Initial
integer(kind=int32), public, allocatable, dimension(:) :: edges

An N-element array containing the edges traversed along the path, in order.

logical, public, allocatable, dimension(:) :: forward

An N-element array that is true if the corresponding edge was traversed from vertex_1 to vertex_2, and false if the edge was traversed from vertex_2 to vertex_1.

integer(kind=int32), public, allocatable, dimension(:) :: vertices

An N+1 element array containing the vertices visited along the path, in order.

type, public ::  spanning_tree

Describes a spanning tree of a graph as generated by a breadth-first traversal.

Components

Type Visibility Attributes Name Initial
integer(kind=int32), public, allocatable, dimension(:) :: depth

An array, one entry per vertex, containing the number of edges between the vertex and the root. Unreachable vertices are assigned a value of -1.

logical, public, allocatable, dimension(:) :: edge_in_tree

An array, one entry per edge, that is true if the edge is part of the spanning tree.

integer(kind=int32), public, allocatable, dimension(:) :: parent_edge

An array, one entry per vertex, containing the index of the edge connecting the vertex to its parent. The root vertex and any unreachable vertices are assigned a value of zero.

logical, public, allocatable, dimension(:) :: parent_edge_forward

An array, one entry per vertex, that is true if the edge connecting the vertex to its parent is traversed from vertex_1 to vertex_2 when moving from the parent to the vertex.

integer(kind=int32), public, allocatable, dimension(:) :: parent_vertex

An array, one entry per vertex, containing the index of the parent vertex. The root vertex and any unreachable vertices are assigned a value of zero.

integer(kind=int32), public :: root = 0

The vertex from which the traversal was started.

integer(kind=int32), public, allocatable, dimension(:) :: visit_order

An array containing the reachable vertices in the order in which they were visited.

Type-Bound Procedures

procedure , public :: get_cut_edges => st_get_cut_edges Function
procedure , public :: get_path => st_get_path Function
procedure , public :: is_connected => st_is_connected Function